package com.hexiang.service;


import java.io.IOException;
import java.util.List;
import java.util.Map;

public interface ElasticSearchService {
    /**
     * 创建索引
     *
     * @param index
     */
    boolean createIndex(String index) throws IOException;

    /**
     * 判断索引是否存在
     *
     * @param index
     */
    boolean existIndex(String index) throws IOException;

    /**
     * 删除索引
     *
     * @param index
     */
    boolean deleteIndex(String index) throws IOException;

    /**
     * 新增文档
     *
     * @param index
     * @param id
     * @param content
     */
    boolean addDocument(String index, String id, String content) throws IOException;

    boolean addDocument(String index, String id, Map<String, Object> jsonMap) throws IOException;

    /**
     * 判断是否存在文档
     *
     * @param index
     * @param id
     */
    boolean isExistsDocument(String index, String id) throws IOException;

    /**
     * 获取文档
     *
     * @param index
     * @param id
     */
    String getDocument(String index, String id) throws IOException;

    /**
     * 更新文档
     *
     * @param index
     * @param id
     * @param content
     */
    boolean updateDocument(String index, String id, String content) throws IOException;

    boolean updateDocument(String index, String id, Map<String, Object> jsonMap) throws IOException;

    /**
     * 删除文档
     *
     * @param index
     * @param id
     */
    boolean deleteDocument(String index, String id) throws IOException;

    /**
     * 批量插入
     *
     * @param index
     * @param contents
     */
    <T> boolean bulkRequest(String index, List<T> contents) throws IOException;

    /**
     * 搜索请求
     *
     * @param index
     * @param keyword
     */
    List<Map<String, Object>> searchRequest(String index, String keyword) throws IOException;

    /**
     * 搜索所有id
     *
     * @param index
     */
    List<String> searchAllRequest(String index) throws IOException;
}

